set hive.exec.dynamic.partition = true;
set hive.exec.dynamic.partition.mode = 'nonstrict';
set hive.exec.max.dynamic.partitions = 400;
set hive.exec.max.dynamic.partitions.pernode = 200;
insert overwrite table jms_dm.dm_tab_in_center_package_waybill_detail_dt partition (dt)
select waybill_no
     , input_site
     , scan_site_code
     , network_type
     , site_agent_code
     , site_agent_name
     , scan_time
     , date_time
     , package_length
     , package_wide
     , package_high
     , goods_type_code
     , goods_type_name
     , package_charge_weight
     , package_code
     , second_code
     , third_code
     , second_package_code
     , third_package_code
     , scan_user
     , pack_scan_time
     , need_way_flag
     , error_pack_way_flag
     , date_time as dt
from jms_dm.dm_tab_in_center_package_waybill_base_detail_dt
where dt between date_add('{{ execution_date | cst_ds }}', -6) and '{{ execution_date | cst_ds }}'
  and ((need_way_flag = 1 and nopack_flag = 1) or error_pack_way_flag = 0)
 distribute by pmod(hash(rand()), 20);
